<?php
namespace App\Model;



use Common\Util\ConfigUtils;

class TopicModel extends BaseModel {

    private static $instance;

    public static function singleton()
    {
        self::$instance === null and self::$instance = new self();
        return self::$instance;
    }


    public function getListByWhere($city_code){
        $where['is_show']=1;

        $rows =$this->where($where)
            ->field('id,topic_code,topic_image,topic_name,prize_color')
            ->order('sort desc')
            ->select();
        foreach ($rows as $key=>$val){
            $rows[$key]['topic_image']=ConfigUtils::getConfig('SERVER_URL').$val['topic_image'];
            $rows[$key]['item_list']=ItemsModel::singleton()->getTopicItem($val['topic_code'],$city_code);
        }

        return $rows;
    }

    /**
     * 根据搜索条件获取所有的用户数量
     * @param $where
     */
    public function getCount($where)
    {
        return $this->where($where)->count();
    }
}